﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Security.Cryptography;

namespace smartphone.SecurityLib
{
    public class PasswordHasher
    {
        private static SHA1Managed hasher = new SHA1Managed();
        public static string Hash(string password)
        {
            //chuyen password thanh mot mang byte
            byte[] passwordBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(password);
            // sinh ma hash tu mang tren
            byte[] passwordHash = hasher.ComputeHash(passwordBytes);
            // chuyen thanh chuoi
            return Convert.ToBase64String(passwordHash, 0, passwordHash.Length);
        }
    }
}